#import "sbrush_instrument_view_updater.h"
#include "dag_threading.h"

using namespace sbrush;
using namespace dag;
using namespace std;
InstrumentViewUpdater::InstrumentViewUpdater(InstrumentView* view)
:	m_InstrumentView(view),
	m_Mutex(new Mutex())
{
}

InstrumentViewUpdater::~InstrumentViewUpdater() throw() {
}

void InstrumentViewUpdater::instrumentCallback(const Instrument* instrument,
											   const InstrumentState& state) {
	ScopedLock sl(*m_Mutex);
	if (m_InstrumentView != NULL) {
		[m_InstrumentView update:&state];
	}
}

void InstrumentViewUpdater::setInstrumentView(InstrumentView* view) {
	ScopedLock sl(*m_Mutex);
	m_InstrumentView = view;
	NSLog(@"set instrument view %@", view);
}

InstrumentView* InstrumentViewUpdater::instrumentView() {
	return m_InstrumentView;
}

